package practice;

import java.util.Scanner;

public class _06Error {
    static int[] a = new int[51];
    static int n;
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        for (int i = 1;i <= n;i++){
            a[i] = scanner.nextInt();
        }
        scanner.close();
        int max = a[1];
        for(int i=1;i<=n;i++) {
            if(a[i]>max){
                max=a[i];
            }
        }

        int l=0,r=max*2;
        while(l<r-1) {
            int mid=(l+r)/2;
            if(select(mid)){
                l=mid;
            } else{
                r=mid;
            }
        }
        System.out.println(r);
    }
    public static boolean select(int find){
        int min = a[1] - find;
        for (int i = 1;i <= n;i++){
            if (a[i] + find >= min+1){
                if (a[i] - find > min){
                    min = a[i] - find;
                }else {
                    min++;
                }
            }else {
                return true;
            }
        }
        return false;
    }

}
